﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/AdminFunction.Master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="BitPortal.Admin.Product.Product.Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .bold-text
        {
            font-weight: bold;
            padding-left: 25px;
            font-size: 110%;
        }
    </style>
    <style type="text/css">
        .x-form-group .x-form-group-header-text
        {
            background-color: #dfe8f6;
        }
        
        .x-label-text
        {
            font-weight: bold;
            font-size: 11px;
        }
    </style>
    <style type="text/css">
        .x-grid3-cell-inner
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
        }
        
        .x-grid-group-hd div
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
        }
        
        .x-grid3-hd-inner
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
            font-size: 12px;
        }
        
        .x-grid3-body .x-grid3-td-Cost
        {
            background-color: #f1f2f4;
        }
        
        .x-grid3-summary-row .x-grid3-td-Cost
        {
            background-color: #e1e2e4;
        }
    </style>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="TopBarHolder" runat="server">
    <ext:ButtonGroup ID="ButtonGroup1" runat="server" Layout="ToolbarLayout">
        <Items>
            <ext:Button runat="server" ID="btnAdd" Text="Thêm sản phẩm" Icon="ControlAddBlue" Scale="Medium"
                CausesValidation="false">
                <DirectEvents>
                    <Click OnEvent="btnAdd_Click">
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:ToolbarSeparator />
            <ext:Button runat="server" ID="btnEdit" Text="Sửa sản phẩm" Icon="Pencil" Scale="Medium"
                CausesValidation="false">
                <DirectEvents>
                    <Click OnEvent="btnEdit_Click">
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:ToolbarSeparator />
            <ext:Button runat="server" ID="btnEditMedia" Text="Thêm Ảnh(video)" Icon="PhotoAdd"
                Scale="Medium" CausesValidation="false">
                <DirectEvents>
                    <Click OnEvent="btnEditMedia_Click">
                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:ToolbarSeparator />
            <ext:Button runat="server" ID="btnUpdate" Text="Cập nhật" Icon="PageEdit" Scale="Medium">
                <Listeners>
                    <Click Handler="#{Window2}.show();" />
                </Listeners>
            </ext:Button>
            <ext:ToolbarSeparator />
            <ext:Button runat="server" ID="btnDelete" Text="Xóa sản phẩm" Icon="Delete" Scale="Medium">
                <DirectEvents>
                    <Click OnEvent="btnDelete_Click">
                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:ToolbarSeparator />
            <ext:SplitButton runat="server" ID="btnTrash" Text="Thùng rác" Icon="Bin" Scale="Medium">
                <Menu>
                    <ext:Menu ID="Menu2" runat="server">
                        <Items>
                            <ext:MenuItem ID="MenuItem8" runat="server" Text="Xóa tất cả" Icon="Cancel">
                                <DirectEvents>
                                    <Click OnEvent="btnTrashEmpty_Click">
                                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                                    </Click>
                                </DirectEvents>
                            </ext:MenuItem>
                            <ext:MenuItem ID="MenuItem9" runat="server" Text="Xóa những SP được chọn" Icon="BinEmpty">
                                <DirectEvents>
                                    <Click OnEvent="btnTrashDelete_Click">
                                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                                    </Click>
                                </DirectEvents>
                            </ext:MenuItem>
                            <ext:MenuItem ID="MenuItem10" runat="server" Text="Bỏ khỏi thùng rác" Icon="ArrowTurnLeft">
                                <DirectEvents>
                                    <Click OnEvent="btnUnDelete_Click">
                                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                                    </Click>
                                </DirectEvents>
                            </ext:MenuItem>
                        </Items>
                    </ext:Menu>
                </Menu>
                <DirectEvents>
                    <Click OnEvent="btnTrash_Click">
                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                    </Click>
                </DirectEvents>
            </ext:SplitButton>
        </Items>
    </ext:ButtonGroup>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <ext:Store ID="Store1" runat="server" OnRefreshData="Store1_RefreshData" RemoteSort="true"
        RemotePaging="true">
        <Proxy>
            <ext:PageProxy />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="ProductID">
                <Fields>
                    <ext:RecordField Name="ProductID" Type="Int" />
                    <ext:RecordField Name="Name" Type="String" />
                    <ext:RecordField Name="ThumbImage" Type="String" />
                    <ext:RecordField Name="Manufactor" Type="String" />
                    <ext:RecordField Name="ProductCategory_Name" Type="String" ServerMapping="ProductCategory.Name" />
                    <ext:RecordField Name="DatetimeDisplay" Type="Date" DateFormat="yyyy-MM-ddTHH:mm:ss" />
                    <ext:RecordField Name="IsEnabled" Type="Boolean" />
                    <ext:RecordField Name="IsHot" Type="Boolean" />
                    <ext:RecordField Name="IsNew" Type="Boolean" />
                    <ext:RecordField Name="IsDiscount" Type="Boolean" />
                    <ext:RecordField Name="AllowOrder" Type="Boolean" />
                    <ext:RecordField Name="Avaiabled" Type="Boolean" />
                    <ext:RecordField Name="CallToPrice" Type="Boolean" />
                    <ext:RecordField Name="Price" Type="Auto" />
                    <ext:RecordField Name="Logs_DatetimeCreated" Type="Date" ServerMapping="Logs.DatetimeCreated" />
                    <ext:RecordField Name="Statistic_ViewCount" Type="Int" ServerMapping="Statistic.ViewCount" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="limit" Value="10" Mode="Raw" />
            <ext:Parameter Name="sort" Value="" />
            <ext:Parameter Name="dir" Value="" />
        </BaseParams>
        <SortInfo Field="ProductID" Direction="DESC" />
    </ext:Store>
    <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true" Title="Danh sách sản phẩm"
        StoreID="Store1">
        <ColumnModel ID="ColumnModel1" runat="server">
            <Columns>
                <ext:Column Header="Mã" DataIndex="ProductID" Groupable="false" />
                <ext:TemplateColumn Header="Ảnh" Groupable="false" Sortable="false">
                    <Template runat="server">
                        <Html>
                            <img src="/Handlers/Thumbnail.ashx?p={ThumbImage}&w=80&h=60" width="80" height="60"
                                alt="" />
                        </Html>
                    </Template>
                </ext:TemplateColumn>
                <ext:GroupingSummaryColumn Header="Danh mục" DataIndex="ProductCategory_Name" Groupable="true"
                    SummaryType="Count">
                    <SummaryRenderer Handler="return ((value === 0 || value > 1) ? '(' + value +' sản phẩm)' : '(1 sản phẩm)');" />
                </ext:GroupingSummaryColumn>
                <ext:Column Header="Tên sp" DataIndex="Name" Groupable="false" />
                <ext:Column Header="Hãng" DataIndex="Manufactor" Groupable="false" />
                <ext:NumberColumn Header="Giá" DataIndex="Price" />
                <ext:Column Header="Lượt xem" DataIndex="Statistic_ViewCount" Align="Center" Groupable="false" />
                <ext:DateColumn Header="Ngày hiển thị" DataIndex="DatetimeDisplay" Align="Center"
                    Format="dd-MM-yyyy" />
                <ext:DateColumn Header="Ngày tạo" DataIndex="Logs_DatetimeCreated" Align="Center"
                    Format="dd-MM-yyyy" />
                <ext:Column Header="Hiển thị" DataIndex="IsEnabled" Align="Center">
                    <Renderer Handler="return (value) ? 'Có':'Không';" />
                </ext:Column>
                <ext:Column Header="Nổi bật" DataIndex="IsHot" Align="Center">
                    <Renderer Handler="return (value) ? 'Có':'Không';" />
                </ext:Column>
                <ext:Column Header="Mới" DataIndex="IsNew" Align="Center">
                    <Renderer Handler="return (value) ? 'Có':'Không';" />
                </ext:Column>
                <ext:Column Header="Giá liên hệ" DataIndex="CallToPrice" Align="Center" Hidden="true">
                    <Renderer Handler="return (value) ? 'Có':'Không';" />
                </ext:Column>
                <ext:Column Header="Còn hàng" DataIndex="Avaiabled" Align="Center" Hidden="true">
                    <Renderer Handler="return (value) ? 'Có':'Không';" />
                </ext:Column>
                <ext:Column Header="Cho phép đặt hàng" DataIndex="AllowOrder" Align="Center" Hidden="true">
                    <Renderer Handler="return (value) ? 'Có':'Không';" />
                </ext:Column>
            </Columns>
        </ColumnModel>
        <SelectionModel>
            <ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server" />
        </SelectionModel>
        <View>
            <ext:GroupingView ID="GroupingView1" runat="server" ForceFit="true" MarkDirty="false"
                ShowGroupName="true" EnableNoGroups="true" HideGroupedColumn="true" ShowGroupsText="Nhóm lại theo cột này" />
        </View>
        <LoadMask ShowMask="true" />
        <Plugins>
            <ext:GridFilters runat="server" ID="GridFilters1">
                <Filters>
                    <ext:NumericFilter DataIndex="ProductID" />
                    <ext:StringFilter DataIndex="Name" />
                    <ext:StringFilter DataIndex="Manufactor" />
                    <ext:StringFilter DataIndex="ProductCategory_Name" />
                    <ext:NumericFilter DataIndex="Price" />
                    <ext:NumericFilter DataIndex="Statistic_ViewCount" />
                    <ext:DateFilter DataIndex="DatetimeDisplay">
                        <DatePickerOptions runat="server" TodayText="Now" />
                    </ext:DateFilter>
                    <ext:DateFilter DataIndex="Logs_DatetimeCreated">
                        <DatePickerOptions runat="server" TodayText="Now" />
                    </ext:DateFilter>
                    <ext:BooleanFilter DataIndex="IsEnabled" />
                    <ext:BooleanFilter DataIndex="IsHot" />
                    <ext:BooleanFilter DataIndex="IsNew" />
                    <ext:BooleanFilter DataIndex="CallToPrice" />
                </Filters>
            </ext:GridFilters>
        </Plugins>
        <BottomBar>
            <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="10" />
        </BottomBar>
    </ext:GridPanel>
    <ext:Window ID="Window2" runat="server" Collapsible="true" Icon="ApplicationEdit"
        Title="Cập nhật thông tin sản phẩm" Width="700" AutoScroll="true" AutoHeight="true"
        Hidden="true" Padding="10" Layout="FormLayout" ButtonAlign="Center">
        <Content>
            <ext:Panel ID="Panel1" runat="server" Layout="Column" Height="160" FormGroup="true"
                Title="Cập nhật hiển thị" Collapsed="false">
                <Items>
                    <ext:Container ID="Container7" runat="server" Layout="Form" ColumnWidth=".3" LabelWidth="150">
                        <Items>
                            <ext:Checkbox runat="server" ID="ckUpdateDiscount" FieldLabel="Cập nhật khuyến mại" />
                            <ext:Checkbox runat="server" ID="ckUpdateNew" FieldLabel="Cập nhật sp phẩm mới" />
                            <ext:Checkbox runat="server" ID="ckUpdateHot" FieldLabel="Cập nhật sp nổi bật" />
                            <ext:Checkbox runat="server" ID="ckUpdateEnabled" FieldLabel="Cập nhật duyệt" />
                            <ext:Checkbox runat="server" ID="ckUpdateAvaiable" FieldLabel="Cập nhật còn hàng" />
                            <ext:Checkbox runat="server" ID="ckUpdateAllowOrder" FieldLabel="Cập nhật đặt hàng" />
                        </Items>
                    </ext:Container>
                    <ext:Container ID="Container8" runat="server" Layout="Form" ColumnWidth=".7">
                        <Items>
                            <ext:Checkbox runat="server" ID="ckIsDiscount" FieldLabel="Có khuyến mại">
                            </ext:Checkbox>
                            <ext:Checkbox runat="server" ID="ckIsNew" FieldLabel="Là SP mới">
                            </ext:Checkbox>
                            <ext:Checkbox runat="server" ID="ckIsHot" FieldLabel="Là SP hot">
                            </ext:Checkbox>
                            <ext:Checkbox runat="server" ID="ckIsEnabled" FieldLabel="Hiển thị">
                            </ext:Checkbox>
                            <ext:Checkbox runat="server" ID="ckAvaiable" FieldLabel="Còn hàng">
                            </ext:Checkbox>
                            <ext:Checkbox runat="server" ID="ckAllowOrder" FieldLabel="Có đặt hàng">
                            </ext:Checkbox>
                        </Items>
                    </ext:Container>
                </Items>
            </ext:Panel>
            <ext:Panel ID="Container1" runat="server" Layout="Column" Height="100" FormGroup="true"
                Title="Cập nhật thông tin" Collapsed="true">
                <Items>
                    <ext:Container ID="Container2" runat="server" Layout="Form" ColumnWidth=".3" LabelWidth="150">
                        <Items>
                            <ext:Checkbox runat="server" ID="ckUpdateManufactor" FieldLabel="Cập nhật hãng sx" />
                            <ext:Checkbox runat="server" ID="ckUpdateWarranty" FieldLabel="Cập nhật tt bảo hành" />
                            <ext:Checkbox runat="server" ID="ckUpdateDatetimeDisplay" FieldLabel="Cập nhật ngày hiển thị" />
                            <ext:Checkbox runat="server" ID="ckUpdateSortorder" FieldLabel="Cập nhật thứ tự" />
                        </Items>
                    </ext:Container>
                    <ext:Container ID="Container3" runat="server" Layout="Form" ColumnWidth=".7">
                        <Items>
                            <ext:TextField ID="txtManufactor" runat="server" AnchorHorizontal="95%" EmptyText="Nhập hãng sản xuất">
                            </ext:TextField>
                            <ext:TextField ID="txtWarranty" runat="server" AnchorHorizontal="95%" EmptyText="Thông tin bảo hành">
                            </ext:TextField>
                            <ext:DateField ID="datetimeDisplay" runat="server" Width="300" Editable="false" />
                            <ext:SpinnerField ID="txtSortOrder" runat="server" Text="0" AllowDecimals="false"
                                MinValue="0" Width="195">
                            </ext:SpinnerField>
                        </Items>
                    </ext:Container>
                </Items>
            </ext:Panel>
            <ext:Panel ID="Container4" runat="server" Layout="Column" Height="100" FormGroup="true"
                Title="Cập nhật giá" Collapsed="true">
                <Items>
                    <ext:Container ID="Container5" runat="server" Layout="Form" ColumnWidth=".3" LabelWidth="150">
                        <Items>
                            <ext:Checkbox runat="server" ID="ckUpdatePrice" FieldLabel="Cập nhật giá" />
                            <ext:Checkbox runat="server" ID="ckUpdateOldPrice" FieldLabel="Cập nhật giá cũ" />
                            <ext:Checkbox runat="server" ID="ckUpdateCost" FieldLabel="Cập nhật giá thực" />
                            <ext:Checkbox runat="server" ID="ckUpdateCallToPrice" FieldLabel="Cập nhật giá liên hệ" />
                        </Items>
                    </ext:Container>
                    <ext:Container ID="Container6" runat="server" Layout="Form" ColumnWidth=".7">
                        <Items>
                            <ext:NumberField ID="txtPrice" runat="server" MinValue="0" Text="0" DecimalSeparator=","
                                Width="250">
                            </ext:NumberField>
                            <ext:NumberField ID="txtOldPrice" runat="server" MinValue="0" Text="0" DecimalSeparator=","
                                Width="250">
                            </ext:NumberField>
                            <ext:NumberField ID="txtCost" runat="server" MinValue="0" Text="0" DecimalSeparator=","
                                Width="250">
                            </ext:NumberField>
                            <ext:Checkbox runat="server" ID="ckCallToPrice">
                            </ext:Checkbox>
                        </Items>
                    </ext:Container>
                </Items>
            </ext:Panel>
        </Content>
        <Buttons>
            <ext:Button runat="server" ID="btnUpdateSelected" Text="Cập nhật">
                <DirectEvents>
                    <Click OnEvent="btnUpdateSelected_Click">
                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:Button ID="btnCancel" runat="server" Text="Bỏ qua">
                <Listeners>
                    <Click Handler="#{Window2}.hide();" />
                </Listeners>
            </ext:Button>
        </Buttons>
    </ext:Window>
    <ext:Window runat="server" ID="wAddEdit" Width="960" Height="550" AutoScroll="true"
        Hidden="true" Icon="ApplicationEdit" Title="Thêm / Cập nhật thông tin sản phẩm" AutoDataBind="false">
        <AutoLoad Url="#" ShowMask="true" Mode="IFrame">
        </AutoLoad>
    </ext:Window>
    <uc:ProductMedia runat="server" ID="ProductMedia1" />
</asp:Content>
